package com.rabbitmq.receivers;

import com.rabbitmq.config.SimpleConfig;
import org.apache.tomcat.util.buf.HexUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 简单模式：一个生产者，一个消费者，一个队列，采用默认交换机
 *
 * @author 王霄
 * @date 2022/1/8 16:46
 */
@Component
@RabbitListener(queues = SimpleConfig.QUEUE_NAME)
public class SimpleReceiver {

    @RabbitHandler
    public void process(String message) {
        System.out.println("接收到简单模式的String消息 : " + message);
    }

    @RabbitHandler
    public void process(Integer message) {
        System.out.println("接收到简单模式的Integer消息 : " + message);
    }

    @RabbitHandler
    public void process(byte[] message) {
        System.out.println("接收到简单模式的byte消息 : " + HexUtils.toHexString(message));
    }

}
